<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:p="http://primefaces.org/ui"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition template="/pages/home.xhtml">
	<ui:define name="title">
		<h:outputText value="#{text.titDependente}" />
	</ui:define>
	<ui:define name="content">
		<p:fieldset id="fieldSetDependente" legend="#{text.lgdDependenteForm}"
			toggleable="true" binding="#{dependenteController.fieldSetDependente}">
			<h:inputHidden id="dependenteId"
				value="#{dependenteController.selectedDependente.idDependente}" />
			<h:panelGrid id="pnlFields" columns="3">

			
				<h:outputLabel for="nome" value="#{text.lblDependenteNome}" />
				<p:inputText id="nome" required="true" size="50" maxlength="40"
					requiredMessage="#{message.requiredDependenteNome}"
					value="#{dependenteController.selectedDependente.nomeDependente}" />
				<p:message for="nome" />

				<h:outputLabel for="cpf" value="#{text.lblDependenteCPF}" />
				<p:inputMask id="cpf" size="20" maxlength="11" mask="99999999999"
					value="#{dependenteController.selectedDependente.numCpf}" />
				<p:message for="cpf" />

				<h:outputLabel for="identidade" value="#{text.lblDependenteIdentidade}" />
				<p:inputMask id="identidade" size="20" maxlength="10"
					mask="9999999999"
					value="#{dependenteController.selectedDependente.numIdentidade}" />
				<p:message for="identidade" />

				<h:outputLabel for="nascimento" value="#{text.lblDependenteNascimento}" />
				<p:calendar id="nascimento" size="20" maxlength="10"
					navigator="true" pattern="dd/MM/yyyy"
					yearRange="c-80:c+0" showButtonPanel="true"
					showOn="both" 
					value="#{dependenteController.selectedDependente.dataNascimento}" />
				<p:message for="nascimento" />


				<h:outputLabel for="socio" value="#{text.lblSocio}" />
				<h:panelGroup>
					<p:inputText id="socio" size="50" maxlength="30" 
					readonly="true" styleClass="inputfield-readonly"
					value="#{dependenteController.selectedDependente.socio.nomeSocio}" />
					<p:spacer width="5px" />
					<p:commandButton icon="ui-icon-search" id="selectSocio"
								update=":frmContent:dlgSocio" process="@none"
								oncomplete="dlgSocio.show()" />
								
					<p:dialog id="dlgSocio" header="#{text.titDlgSocio}"
						appendToBody="false" widgetVar="dlgSocio" modal="false"
						resizable="false" styleClass="dlgSelect" >

						<p:dataTable id="grdSocio" var="socio"
							value="#{dependenteController.socioDataModel}"
							widgetVar="grdSocio" emptyMessage="#{text.grdEmpty}"
							selection="#{dependenteController.selectedSocio}"
							paginator="true" rows="10"
							paginatorPosition="bottom" sortBy="#{socio.nomeSocio}" paginatorAlwaysVisible="false"
							paginatorTemplate=" {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
							style="width:600px;" filterEvent="enter">
							<p:column selectionMode="single" style="width:18px" />
							<p:column id="colSocioNome" headerText="#{text.lblSocioNome}"
								sortBy="#{socio.nomeSocio}" filterBy="#{socio.nomeSocio}">
								<h:outputText value="#{socio.nomeSocio}" />
							</p:column>
							<f:facet name="footer">
								<p:commandButton value="#{text.btnConfirm}"
									oncomplete="dlgSocio.hide();"
									process=":frmContent:grdSocio"
									update=":frmContent:socio"
									actionListener="#{dependenteController.selectSocio}" />
								<p:commandButton value="#{text.btnCancel}" global="false"
									onclick="dlgSocio.hide();" />
							</f:facet>
						</p:dataTable>
					</p:dialog>
				</h:panelGroup>
				<p:message for="socio" />





				<h:outputLabel for="parentesco" value="#{text.lblParentesco}" />
				<p:selectOneMenu id="parentesco" effect="fade"
					value="#{dependenteController.selectedDependente.parentesco.id}"  >
					<f:selectItem itemLabel="#{text.lblUnselectCombo}" itemValue="" />
					<f:selectItems value="#{dependenteController.parentescoList}"
						var="parent" 
						itemLabel="#{parent.descParentesco}"
						itemValue="#{parent.id}" />
				</p:selectOneMenu>
				<p:message for="parentesco" />

				
			</h:panelGrid>


			<p:separator />

			<p:commandButton id="btnNew" value="#{text.btnNew}"
				icon="ui-icon-document" actionListener="#{dependenteController.newDependente}"
				immediate="true" update=":frmContent:fieldSetDependente"
				onclick="grdDependente.unselectAllRows();clearRadioDataTable();" />
			<p:commandButton id="btnSave" value="#{text.btnSave}"
				icon="ui-icon-disk"
				update=":frmContent:fieldSetDependente, :frmContent:grdDependente"
				actionListener="#{dependenteController.saveDependente}"
				process=":frmContent:fieldSetDependente" />
			<p:commandButton id="btnDelete" value="#{text.btnDelete}"
				icon="ui-icon-trash" onclick="dialogDelete.show()"
				binding="#{dependenteController.btnDelete}" disabled="true" />
			<p:confirmDialog id="dlgConfirmDelete" widgetVar="dialogDelete"
				closable="true" severity="info" appendToBody="true"
				header="#{text.dlgConfirm}" message="#{message.confirmDelete}"
				width="400">
				<p:commandButton id="btnConfirmDelete"
					actionListener="#{dependenteController.deleteDependente}"
					value="#{text.btnConfirm}" icon="ui-icon-check"
					oncomplete="dialogDelete.hide()"
					update=":frmContent:fieldSetDependente, :frmContent:grdDependente" />
				<p:commandButton id="btnDeclineDelete" onclick="dialogDelete.hide()"
					value="#{text.btnCancel}" icon="ui-icon-cancel" />
			</p:confirmDialog>

		</p:fieldset>

		<p:spacer height="25" />

		<p:dataTable id="grdDependente" var="dependente"
			value="#{dependenteController.dependenteDataModel}"
			widgetVar="grdDependente" emptyMessage="#{text.grdEmpty}"
			selection="#{dependenteController.selectedDependente}"
			paginator="true" rows="10" rowsPerPageTemplate="10,25,50"
			paginatorTemplate=" {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
			style="width:600px;" sortBy="#{dependente.nomeDependente}">

			<p:ajax event="rowSelect" update=":frmContent:fieldSetDependente"
				listener="#{dependenteController.selectDependente}"/>

			<p:column selectionMode="single" style="width:18px" />
			<p:column id="colDependenteDesc"
				headerText="#{text.lblDependenteNome}"
				sortBy="#{dependente.nomeDependente}">
				<h:outputText value="#{dependente.nomeDependente}" />
			</p:column>
			<p:column id="colDependenteNascimento"
				headerText="#{text.lblDependenteNascimento}"
				sortBy="#{dependente.dataNascimento}">
				<h:outputText id="colDependenteNascimentoText"
					value="#{dependente.dataNascimento}">
					<f:convertDateTime for="colDependenteNascimentoText"
						pattern="dd/MM/yyyy" />
				</h:outputText>
			</p:column>
			<p:column id="colDependenteParentesco"
				headerText="#{text.lblDependenteParentesco}"
				sortBy="#{dependente.parentesco.descParentesco}">
				<h:outputText value="#{dependente.parentesco.descParentesco}" />
			</p:column>
		</p:dataTable>


	</ui:define>
</ui:composition>

</html>